﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZhouYu.NewWorld.BLL.IService;
using ZhouYu.NewWorld.Model;
using ZhouYu.NewWorld.ViewModel;

namespace ZhouYu.NewWorld.Web.Controllers
{
    public class TravelVoController : Controller
    {
        //注入
        private ITravelVoService _travelVoService;
        public TravelVoController(ITravelVoService travelVoService)
        {
            _travelVoService = travelVoService;
        }

        /// <summary>
        /// 旅游卷列表查询
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        /// <returns></returns>
        public JsonResult GetTravelVoList(int page, int limit)
        {
            //创建返回结果对象
            ResponseResult responseResult = new ResponseResult();
            responseResult = _travelVoService.GetTravelVoList(page, limit);
            return Json(responseResult, JsonRequestBehavior.AllowGet);
        }


        /// <summary>
        /// 删除旅游卷操作记录
        /// </summary>
        /// <param name="vouncherInfo"></param>
        /// <returns></returns>
        public JsonResult DelTravelVo(TravelVoInfo travelvoInfo)
        {
            //给操作记录对象赋值
            Travelvo_record travelvo_Record = new Travelvo_record();
            travelvo_Record.TravelVoRecord_Id = travelvoInfo.TravelVoRecord_Id;
            //创建返回结果对象
            ResponseResult responseResult = new ResponseResult();
            responseResult = _travelVoService.DeleteRecord(travelvo_Record);
            return Json(responseResult, JsonRequestBehavior.AllowGet);//JsonRequestBehavior.AllowGet参数：防止数据不安全泄露
        }


        /// <summary>
        /// 删除抵用卷和抵用卷操作记录
        /// </summary>
        /// <param name="vouncherInfo"></param>
        /// <returns></returns>
        public JsonResult DelAllTravelVo(TravelVoInfo travelVoInfo)
        {
            //给抵用卷对象赋值
            Travelvo travelvo = new Travelvo();
            travelvo.TravelVo_Id = travelVoInfo.TravelVo_Id;
            //创建返回结果对象
            ResponseResult responseResult = new ResponseResult();
            responseResult = _travelVoService.DelAllTravelVo(travelvo);
            return Json(responseResult, JsonRequestBehavior.AllowGet);//JsonRequestBehavior.AllowGet参数：防止数据不安全泄露
        }


        /// <summary>
        /// 修改旅游卷信息
        /// </summary>
        /// <param name="vouncherInfo"></param>
        /// <returns></returns>
        public JsonResult EditTravelVo(Travelvo travelvo)
        {
            //创建返回结果对象
            ResponseResult responseResult = new ResponseResult();
            responseResult.Success = _travelVoService.Update(travelvo);
            return Json(responseResult, JsonRequestBehavior.AllowGet);//JsonRequestBehavior.AllowGet参数：防止数据不安全泄露
        }


        /// <summary>
        /// 发送旅游卷
        /// </summary>
        /// <param name="vouncherInfo"></param>
        /// <returns></returns>
        public JsonResult AddTravelVo(Travelvo travelvo)
        {
            //创建返回结果对象
            ResponseResult responseResult = new ResponseResult();
            //给修改时间赋值
            travelvo.TravelVo_CreateTime = DateTime.Now;
            responseResult = _travelVoService.AddTravelVo(travelvo);
            return Json(responseResult, JsonRequestBehavior.AllowGet);//JsonRequestBehavior.AllowGet参数：防止数据不安全泄露
        }
    }
}